<!DOCTYPE html>
<html lang="en">


{include file="Public/head"}

<body data-type="widgets">
<script src="/assets/js/theme.js"></script>
<div class="am-g tpl-g">

    {include file='Public:header'}
    {include file='Public:menu2'}



    <!-- 内容区域 -->
    <div class="tpl-content-wrapper">
        <div class="row-content am-cf">
            <div class="row">
                <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                    <div class="widget am-cf">
                        <div class="widget-head am-cf">
                            <div class="widget-title  am-cf">会员列表</div>
                        </div>
                        <div class="widget-body  am-fr">

                            <div class="am-u-sm-12 am-u-md-6 am-u-lg-1" >
                                <div class="am-form-group" >
                                    <div class="am-btn-toolbar" >
                                        <div class="am-btn-group am-btn-group-xs" >
                                            <a href="{:Url('add')}" class="am-btn am-btn-default am-btn-success" ><span class="am-icon-plus" ></span> 新增</a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!--筛选搜索-->
                            <form action=""></form>
                            <form id="searchform" action="{:Url('index')}"  method="get" class="am-form tpl-form-border-form tpl-form-border-br">
                                <div class="am-u-sm-12 am-u-md-6 am-u-lg-1">
                                    <div class="am-form-group tpl-table-list-select">
                                        <select data-am-selected="{btnSize: 'sm'}" name="level_id">
                                            <option value="-1">选择等级</option>
                                            {foreach name="lever" key="key" item="value"}
                                            <option value="{$value.level_id}">{$value.level_name}</option>
                                            {/foreach}
                                        </select>
                                    </div>
                                </div>
                                <div class="am-u-sm-12 am-u-md-12 am-u-lg-2">
                                    <div class="am-input-group am-input-group-sm tpl-form-border-form cl-p">
                                        <input type="text" class="am-form-field " name="mobile" placeholder="手机号">
                                        <span class="am-input-group-btn">
                                            <!--<input class="btn btn-info" type="button" onclick="roleSubmit()" value="提交">-->

                                            <button class="am-btn  am-btn-default am-btn-success tpl-table-list-field am-icon-search" type="submit" ></button>
                                        </span>
                                    </div>
                                </div>
                            </form>
                            <div class="am-u-sm-12">
                                <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black " id="example-r">
                                    <thead>
                                    <tr>

                                        <th>会员昵称</th>
                                        <th>会员等级</th>
                                        <th>累计消费</th>
                                        <th>邮箱</th>
                                        <!--<th>一级下线数</th>-->
                                        <!--<th>二级下线数</th>-->
                                        <!--<th>三级下线数</th>-->
                                        <th>手机号码</th>
                                        <th>余额</th>
                                        <th>累积消费金额</th>
                                        <!--<th>积分</th>-->
                                        <th>加入时间</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    {foreach name="data" key="key" item="value"}
                                    <tr class="gradeX">
                                        <td>{$value.nickname}</td>
                                        <td>{$value.level_name}</td>
                                        <td>{$value.accu_money}</td>
                                        <td>{$value.email}</td>

                                        <!--<td>{$first[$value['user_id']]}</td>-->
                                        <!--<td>{$second[$value['user_id']]}</td>-->
                                        <!--<td>{$third[$value['user_id']]}</td>-->

                                        <td>{$value.mobile}</td>
                                        <td>{$value.user_money}</td>
                                        <td>{$value.accu_money}</td>
                                        <!--<td>{$value.pay_points}</td>-->
                                        <td>{if $value.reg_time=='0'}未绑定手机{else}{$value.reg_time|date='Y-m-d H:i:s',###}{/if}</td>
                                        <td>
                                            <div class="tpl-table-black-operation">
                                                <a href="{:Url('add')}?user_id={$value.user_id}">
                                                    <i class="am-icon-pencil"></i> 编辑
                                                </a>
                                                <a href="{:Url('toHome')}?user_id={$value.user_id}" class="tpl-table-black-operation-set">
                                                    <i class="fa fa-home"></i> 地址
                                                </a>
                                                <a href="{:Url('accountLog')}?user_id={$value.user_id}" class="tpl-table-black-operation-set">
                                                    <i class="fa fa-home"></i> 账本
                                                </a>
                                                <a onclick="del_button({$value.user_id});" href="javascript:void(0);" href="javascript:;" class="tpl-table-black-operation-del">
                                                    <i class="am-icon-trash"></i> 删除
                                                </a>
                                            </div>
                                        </td>
                                    </tr>
                                    {/foreach}
                                    <!-- more data -->
                                    </tbody>
                                </table>
                            </div>
                            <div class="am-u-lg-10 am-cf">

                                <div class="am-fr">
                                    <ul class="am-pagination tpl-pagination">
                                        {$data->render()}
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>

</body>
{include file='Public:script'}
<script>
    // 删除按钮
    function del_button(id, className) {
        layer.confirm("确定删除？", {btn: ["确定","取消"], shade: 0.5}, function(){
            // 删除权限组
            $.post("{:url('del')}", {id: id}, function(res) {
                if (res.code != 200) {
                    layer.msg(res.msg, {shade: 0.5, time: 1000, icon: 2});
                    return false;
                }

                layer.msg(res.msg, {shade: 0.5, time: 1000, icon: 1}, function() {
                    layer.closeAll('page');
                    location.reload();
                });
            });
        }, function () {});
    }

    //提交
    function roleSubmit() {
        var form = document.getElementById("searchform");
        var formData = new FormData(form);
        $.ajax({
            url: "{:Url('index')}",
            type: 'POST',
            data: formData,
            async: false,
            cache: false,
            contentType: false, //不设置内容类型
            processData: false, //不处理数据
            success: function (res) {
                console.log(res);
                if (res.code != 200) {
                    layer.msg(res.msg, {shade: 0.5, time: 2000, icon: 2});
                    return false;
                }
                layer.msg(res.msg, {shade: 0.5, time: 2000, icon: 1}, function () {
                    window.location.href = document.referrer;

                });
            }
        })
    }
</script>
</html>